import {defineStore} from 'pinia'

export const useSystem = defineStore('system', {
    state: () => ({
        theme: {
            // 深色系主题
            dark: {
                bg: '#724d15',
                shallowBgColor:'rgb(210,237,222)',
                infoColor: 'blue',
                inColor: 'yellow',
                outColor: 'blue',
                shallowInColor: 'rgb(44,35,16)',
                shallowOutColor: 'rgb(43,51,46)',
                borderBottomStyle: '2px dashed blue',
                moneyColor: 'blue',
                emptyPageColor: 'blue',
                outColorChatList: [
                    'rgb(72,105,87)',
                    'rgb(104,147,124)',
                    'rgb(65,124,93)',
                    'rgb(51,128,87)',
                    'rgb(34,101,65)',
                    'rgb(141,204,171)',
                    'rgb(47,134,88)',
                    'rgb(77,141,106)',
                    'rgb(183,190,186)',
                    'rgb(152,161,158)'
                ],
                inColorChatList: [
                    'rgb(47,46,42)',
                    'rgb(341,190,77)',
                    'rgb(243,197,97)',
                    'rgb(244,204,117)',
                    'rgb(246,212,137)',
                    'rgb(247,219,156)',
                    'rgb(249,226,176)',
                    'rgb(250,233,196)',
                    'rgb(252,241,216)',
                    'rgb(253,248,235)']

            },
            // 浅色系主题
            light: {
                bg: 'red',
                shallowBgColor:'rgb(210,237,222)',
                infoColor: '#666',
                inColor: '#724d15',
                outColor: '#768d81',
                shallowInColor: 'rgb(250,233,196)',
                shallowOutColor: 'rgb(210,237,222)',
                borderBottomStyle: '2px dashed #eee',
                moneyColor: 'white',
                emptyPageColor: '#ccc',
                outColorChatList: [
                    'rgb(62,181,117)',
                    'rgb(81,188,131)',
                    'rgb(101,196,145)',
                    'rgb(120,203,158)',
                    'rgb(139,211,172)',
                    'rgb(158,218,186)',
                    'rgb(178,225,200)',
                    'rgb(197,233,213)',
                    'rgb(216,240,227)',
                    'rgb(235,247,241)'
                ],
                inColorChatList: [
                    'rgb(240,183,58)',
                    'rgb(341,190,77)',
                    'rgb(243,197,97)',
                    'rgb(244,204,117)',
                    'rgb(246,212,137)',
                    'rgb(247,219,156)',
                    'rgb(249,226,176)',
                    'rgb(250,233,196)',
                    'rgb(252,241,216)',
                    'rgb(253,248,235)']
            },


            // 默认主题
            defaultTheme: {
                bg: '#4f84ff',
                shallowBgColor:'rgb(210,237,222)',
                infoColor: '#666',
                inColor: '#f9ae3d',
                outColor: '#4f84ff',
                shallowInColor: 'rgb(250,233,196)',
                shallowOutColor: 'rgb(210,237,222)',
                borderBottomStyle: '2px dashed #eee',
                moneyColor: 'white',
                emptyPageColor: '#ccc',
                outColorChatList: [
                    'rgb(62,181,117)',
                    'rgb(81,188,131)',
                    'rgb(101,196,145)',
                    'rgb(120,203,158)',
                    'rgb(139,211,172)',
                    'rgb(158,218,186)',
                    'rgb(178,225,200)',
                    'rgb(197,233,213)',
                    'rgb(216,240,227)',
                    'rgb(235,247,241)'
                ],
                inColorChatList: [
                    'rgb(240,183,58)',
                    'rgb(341,190,77)',
                    'rgb(243,197,97)',
                    'rgb(244,204,117)',
                    'rgb(246,212,137)',
                    'rgb(247,219,156)',
                    'rgb(249,226,176)',
                    'rgb(250,233,196)',
                    'rgb(252,241,216)',
                    'rgb(253,248,235)']
            },

            // 当前主题
            type: ''
        },

    }),
    getters: {
        // 主题色
        bg() {
            this.setType()
            return this.theme[this.theme.type].bg
        },
        inColor() {
            this.setType()
            return this.theme[this.theme.type].inColor
        },
        outColor() {
            this.setType()
            return this.theme[this.theme.type].outColor
        },
        borderBottomStyle() {
            this.setType()
            return this.theme[this.theme.type].borderBottomStyle
        },
        // 设置金额显示的颜色 首页顶部的金额统计 统计图金额统计等
        moneyColor() {
            this.setType()
            return this.theme[this.theme.type].moneyColor
        },
        infoColor() {
            this.setType()
            return this.theme[this.theme.type].infoColor
        },
        inColorChatList() {
            this.setType()
            return this.theme[this.theme.type].inColorChatList
        },
        outColorChatList() {
            this.setType()
            return this.theme[this.theme.type].outColorChatList
        },
        shallowInColor() {
            this.setType()
            return this.theme[this.theme.type].shallowInColor
        },
        shallowOutColor() {
            this.setType()
            return this.theme[this.theme.type].shallowOutColor
        },
        shallowBgColor() {
            this.setType()
            return this.theme[this.theme.type].shallowBgColor
        }
    },
    actions: {
        //修改主题色
        changeTheme() {
            let type = uni.getStorageSync('type');
            if (type === 'dark') {
                type = 'defaultTheme'
            } else {
                type = 'dark';
            }
            uni.setStorageSync('type', type);
            this.theme.type = type
        },
        setType() {
            if (this.theme.type === '') {
                let type = uni.getStorageSync('type');
                if (type === undefined || type == null || type === '') {
                    type = 'defaultTheme'
                }
                this.theme.type = type
            }
        }
    }
})